﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace EFong.Contract
{
    [DataContract]
    public class FlightWay
    {
        private Guid _id = Guid.NewGuid();
        [DataMember]
        public Guid ID
        {
            get { return _id; }
            set { _id = value; }
        }

        private string _departLocation = string.Empty;
        [DataMember]
        public string DepartLocation
        {
            get { return _departLocation; }
            set { _departLocation = value; }
        }

        public DateTime? DBDepartDate
        {
            set
            {
                DepartDate = value;
                if (value != null)
                    出发时间 = value.Value.ToString("HHmm");
            }
        }

        private DateTime? _departDate;
        [DataMember]
        public DateTime? DepartDate
        {
            get { return _departDate; }
            set { _departDate = value; }
        }

        private string _出发时间;
        [DataMember]
        public string 出发时间
        {
            get 
            {
                return _出发时间;
                //if (DepartDate == null)
                //    return string.Empty;
                //else
                //    return DepartDate.Value.ToString("hhmm");
            }
            set 
            {
                _出发时间 = value;
                //string sHour = value.Substring(0, 2);
                //string sMinute = value.Substring(2, 2);
                //int hour = Convert.ToInt32(sHour);
                //int minute = Convert.ToInt32(sMinute);

                //if (DepartDate == null)
                //    DepartDate = DateTime.Now;

                //DepartDate = new DateTime(DepartDate.Value.Year, DepartDate.Value.Month, DepartDate.Value.Day, hour, minute, 0);

            }
        }

        private string _destination = string.Empty;
        [DataMember]
        public string Destination
        {
            get { return _destination; }
            set { _destination = value; }
        }
        private string _flightNo = string.Empty;
        [DataMember]
        public string FlightNo
        {
            get { return _flightNo; }
            set { _flightNo = value; }
        }

        private string _seat = string.Empty;
        [DataMember]
        public string Seat
        {
            get { return _seat; }
            set { _seat = value; }
        }

        private bool _isDelete = false;
        [DataMember]
        public bool IsDelete
        {
            get { return _isDelete; }
            set { _isDelete = value; }
        }

        public override bool Equals(object obj)
        {
            FlightWay temp = obj as FlightWay;
            if (temp == null)
                return false;
            return (this.ID.Equals(temp.ID));
        }
    }
}
